function OUT = Symbol_Demapping (IN_Symbols,Rate,type)

%*------------------------- Symbol_Demapping -----------------------------------------%
%
% Symbol_Demapping
%
% the function that demapps the input symbols sequence into corressponging
% bits depend on the rate (constellation demapping).
%
%if type=1, will outs the symbols, and other wise will outs the bits
%*-----------------------------------------------------------------------------------*%
LUT_Rate_Symbols = [2 3 4 5 6 6];
Data_Rates = [3200 4800 6400 8000 9600 12800];
Rate_Index = find(Data_Rates==Rate);
N_Symbols = LUT_Rate_Symbols(Rate_Index);

if (Rate == 3200)
    LUT_Symbol = [0 0 1 1 3 3 2 2];
    Symbols_Gray = LUT_Symbol (IN_Symbols+1);    
    OUT_Bits = de2bi(Symbols_Gray,N_Symbols);
elseif (Rate == 4800)
    LUT_Symbol = [1 0 2 3 7 6 4 5];
    Symbols_Gray = LUT_Symbol (IN_Symbols+1);
    OUT_Bits = de2bi(Symbols_Gray,N_Symbols);
else
    Symbols_Gray = IN_Symbols;
    OUT_Bits = de2bi(IN_Symbols,N_Symbols);
end

if type == 1
    OUT = Symbols_Gray;
else
    OUT = OUT_Bits;
end

